#THIS FILE IS AUTO GENERATED FROM THE TEMPLATE! DO NOT CHANGE!
# 设置交叉编译的系统名称为 Generic，系统版本为 1
set(CMAKE_SYSTEM_NAME Generic)
set(CMAKE_SYSTEM_VERSION 1)
# 指定最低的 CMake 版本要求
cmake_minimum_required(VERSION 3.30)

# specify cross compilers and tools
# 指定交叉编译的工具
set(CMAKE_C_COMPILER arm-none-eabi-gcc)
set(CMAKE_CXX_COMPILER arm-none-eabi-g++)
set(CMAKE_ASM_COMPILER  arm-none-eabi-gcc)
set(CMAKE_AR arm-none-eabi-ar)
set(CMAKE_OBJCOPY arm-none-eabi-objcopy)
set(CMAKE_OBJDUMP arm-none-eabi-objdump)
set(SIZE arm-none-eabi-size)
set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY)

# project settings
# 项目设置
project(template C CXX ASM)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_C_STANDARD 11)

#Uncomment for hardware floating point
add_compile_definitions(ARM_MATH_CM4;ARM_MATH_MATRIX_CHECK;ARM_MATH_ROUNDING)
add_compile_options(-mfloat-abi=hard -mfpu=fpv4-sp-d16)
add_link_options(-mfloat-abi=hard -mfpu=fpv4-sp-d16)

#Uncomment for software floating point
# add_compile_options(-mfloat-abi=soft)

add_compile_options(-mcpu=cortex-m4 -mthumb -mthumb-interwork)
add_compile_options(-ffunction-sections -fdata-sections -fno-common -fmessage-length=0)

# uncomment to mitigate c++17 absolute addresses warnings
#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-register")

# Enable assembler files preprocessing
# add_compile_options($<$<COMPILE_LANGUAGE:ASM>:-x$<SEMICOLON>assembler-with-cpp>)

if ("${CMAKE_BUILD_TYPE}" STREQUAL "Release")
    message(STATUS "Maximum optimization for speed")
    add_compile_options(-Ofast)
elseif ("${CMAKE_BUILD_TYPE}" STREQUAL "RelWithDebInfo")
    message(STATUS "Maximum optimization for speed, debug info included")
    add_compile_options(-Ofast -g)
elseif ("${CMAKE_BUILD_TYPE}" STREQUAL "MinSizeRel")
    message(STATUS "Maximum optimization for size")
    add_compile_options(-Os)
else ()
    message(STATUS "Minimal optimization, debug info included")
    add_compile_options(-Og -g)
endif ()

add_definitions(-DDEBUG 
                -DUSE_STDPERIPH_DRIVER 
                -DSTM32F411xE 
                -DARM_MATH_CM4 
                -DLV_CONF_INCLUDE_SIMPLE)

# 链接源文件 # 配置头文件搜索路径
include_directories(../../Drivers/CMSIS/Include
                    ../../Drivers/CMSIS/Device/ST/STM32F4xx/Include
                    ../../Drivers/STM32F4xx_StdPeriph_Driver/inc
                    ../../Core/Inc
                    ../../Middlewares/FreeRTOS/include
                    ../../Middlewares/FreeRTOS/portable/GCC/ARM_CM4F
                    ../../Bsp
                    ../../App
                    ../../Gui
                    ../../Module
                    ../../Package
                    ../../Middlewares
                    ../../Middlewares/lvgl
                    ../../Middlewares/lvgl/ports
                    ../../Middlewares/lvgl/src
                    ../../Middlewares/lvgl/src/core
                    ../../Middlewares/lvgl/src/draw
                    ../../Middlewares/lvgl/src/extra
                    ../../Middlewares/lvgl/src/hal
                    ../../Middlewares/lvgl/src/misc
                    ../../Middlewares/lvgl/src/widgets
                    ../../Middlewares/lvgl/demos
                    ../../Middlewares/SEGGER/RTT)

# 文件 # 设置源文件列表

# 添加可执行文件
file(GLOB_RECURSE SOURCES 
    ../../Drivers/CMSIS/Device/ST/STM32F4xx/Source/Templates/gcc_ride7/startup_stm32f40xx.s
    ../../Core/Src/main.c
    ../../Core/Src/stm32f4xx_it.c
    ../../App/app.c
    ../../App/Task/app_lvgl_task.c
    ../../App/Task/app_sensor_task.c
    ../../App/Task/app_button_task.c
    ../../Bsp/bsp.c
    ../../Bsp/Src/bsp_aht21.c
    ../../Bsp/Src/bsp_lcd_st7789.c
    ../../Bsp/Src/bsp_at24cxx.c
    ../../Bsp/Src/bsp_touch_cst816.c
    ../../Bsp/Src/bsp_lsm303.c
    ../../Bsp/Src/bsp_key.c
    ../../Bsp/Src/bsp_mpu6050.c
    ../../Bsp/Src/bsp_rtc.c
    ../../Gui/display.c
    ../../Gui/Page/Page_Startup.c
    ../../Gui/Page/Page_Home.c
    ../../Gui/Page/Page_Menu.c
    ../../Gui/Image/ImgBg.c
    ../../Gui/Image/image_bg.c
    ../../Gui/Image/image_icon_humi.c
    ../../Gui/Image/image_icon_temp.c
    ../../Gui/Image/image_icon_avatar.c
    ../../Gui/Image/image_ys.c
    ../../Gui/Font/font_agencyb_36.c
    ../../Gui/Font/font_ds_digital_bold_24.c
    ../../Gui/Font/font_ds_digital_bold_72.c
    ../../Module/module.c
    ../../Module/LOG/log.c
    ../../Module/AHT21/aht21.c
    ../../Module/LCD/lcd.c
    ../../Module/LCD/lcd_font.c
    ../../Module/EEPROM/eeprom.c
    ../../Module/MPU6050/mpu6050.c
    ../../Module/MPU6050/dmp/inv_mpu.c
    ../../Module/MPU6050/dmp/inv_mpu_dmp_motion_driver.c
    ../../Module/BUTTON/mbutton.c
    ../../Package/SW_I2C/sw_i2c.c
    ../../Package/SW_I2C/sw_i2c_ex.c
    ../../Package/SW_SPI/sw_spi.c
    ../../Package/MultiButton/multi_button.c
    ../../Package/PageManager/page_manager.c
    ../../Drivers/CMSIS/Device/ST/STM32F4xx/Source/Templates/system_stm32f4xx.c
    ../../Drivers/STM32F4xx_StdPeriph_Driver/src/misc.c
    ../../Drivers/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_adc.c
    ../../Drivers/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_can.c
    ../../Drivers/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_cec.c
    ../../Drivers/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_crc.c
    ../../Drivers/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_cryp.c
    ../../Drivers/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_cryp_aes.c
    ../../Drivers/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_cryp_des.c
    ../../Drivers/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_cryp_tdes.c
    ../../Drivers/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_dac.c
    ../../Drivers/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_dbgmcu.c
    ../../Drivers/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_dcmi.c
    ../../Drivers/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_dfsdm.c
    ../../Drivers/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_dma.c
    ../../Drivers/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_dma2d.c
    ../../Drivers/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_dsi.c
    ../../Drivers/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_exti.c
    ../../Drivers/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_flash.c
    ../../Drivers/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_flash_ramfunc.c
    # ../../Drivers/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_fmc.c
    ../../Drivers/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_fmpi2c.c
    # ../../Drivers/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_fsmc.c
    ../../Drivers/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_gpio.c
    ../../Drivers/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_hash.c
    ../../Drivers/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_hash_md5.c
    ../../Drivers/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_hash_sha1.c
    ../../Drivers/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_i2c.c
    ../../Drivers/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_iwdg.c
    ../../Drivers/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_lptim.c
    ../../Drivers/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_ltdc.c
    ../../Drivers/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_pwr.c
    ../../Drivers/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_qspi.c
    ../../Drivers/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_rcc.c
    ../../Drivers/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_rng.c
    ../../Drivers/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_rtc.c
    ../../Drivers/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_sai.c
    ../../Drivers/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_sdio.c
    ../../Drivers/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_spdifrx.c
    ../../Drivers/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_spi.c
    ../../Drivers/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_syscfg.c
    ../../Drivers/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_tim.c
    ../../Drivers/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_usart.c
    ../../Drivers/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_wwdg.c
    ../../Middlewares/SEGGER/RTT/SEGGER_RTT.c
    ../../Middlewares/SEGGER/RTT/SEGGER_RTT_printf.c
    ../../Middlewares/FreeRTOS/croutine.c
    ../../Middlewares/FreeRTOS/event_groups.c
    ../../Middlewares/FreeRTOS/list.c
    ../../Middlewares/FreeRTOS/queue.c
    ../../Middlewares/FreeRTOS/stream_buffer.c
    ../../Middlewares/FreeRTOS/tasks.c
    ../../Middlewares/FreeRTOS/timers.c
    ../../Middlewares/FreeRTOS/portable/MemMang/heap_4.c
    ../../Middlewares/FreeRTOS/portable/GCC/ARM_CM4F/port.c
    ../../Middlewares/lvgl/ports/lv_port_disp.c
    ../../Middlewares/lvgl/ports/lv_port_indev.c
    ../../Middlewares/lvgl/src/core/lv_disp.c
    ../../Middlewares/lvgl/src/core/lv_event.c
    ../../Middlewares/lvgl/src/core/lv_group.c
    ../../Middlewares/lvgl/src/core/lv_indev.c
    ../../Middlewares/lvgl/src/core/lv_indev_scroll.c
    ../../Middlewares/lvgl/src/core/lv_obj.c
    ../../Middlewares/lvgl/src/core/lv_obj_class.c
    ../../Middlewares/lvgl/src/core/lv_obj_draw.c
    ../../Middlewares/lvgl/src/core/lv_obj_pos.c
    ../../Middlewares/lvgl/src/core/lv_obj_scroll.c
    ../../Middlewares/lvgl/src/core/lv_obj_style.c
    ../../Middlewares/lvgl/src/core/lv_obj_style_gen.c
    ../../Middlewares/lvgl/src/core/lv_obj_tree.c
    ../../Middlewares/lvgl/src/core/lv_refr.c
    ../../Middlewares/lvgl/src/core/lv_theme.c
    ../../Middlewares/lvgl/src/draw/lv_draw.c
    ../../Middlewares/lvgl/src/draw/lv_draw_arc.c
    ../../Middlewares/lvgl/src/draw/lv_draw_img.c
    ../../Middlewares/lvgl/src/draw/lv_draw_label.c
    ../../Middlewares/lvgl/src/draw/lv_draw_layer.c
    ../../Middlewares/lvgl/src/draw/lv_draw_line.c
    ../../Middlewares/lvgl/src/draw/lv_draw_mask.c
    ../../Middlewares/lvgl/src/draw/lv_draw_rect.c
    ../../Middlewares/lvgl/src/draw/lv_draw_transform.c
    ../../Middlewares/lvgl/src/draw/lv_draw_triangle.c
    ../../Middlewares/lvgl/src/draw/lv_img_buf.c
    ../../Middlewares/lvgl/src/draw/lv_img_cache.c
    ../../Middlewares/lvgl/src/draw/lv_img_decoder.c
    ../../Middlewares/lvgl/src/draw/sw/lv_draw_sw.c
    ../../Middlewares/lvgl/src/draw/sw/lv_draw_sw_arc.c
    ../../Middlewares/lvgl/src/draw/sw/lv_draw_sw_blend.c
    ../../Middlewares/lvgl/src/draw/sw/lv_draw_sw_dither.c
    ../../Middlewares/lvgl/src/draw/sw/lv_draw_sw_gradient.c
    ../../Middlewares/lvgl/src/draw/sw/lv_draw_sw_img.c
    ../../Middlewares/lvgl/src/draw/sw/lv_draw_sw_layer.c
    ../../Middlewares/lvgl/src/draw/sw/lv_draw_sw_letter.c
    ../../Middlewares/lvgl/src/draw/sw/lv_draw_sw_line.c
    ../../Middlewares/lvgl/src/draw/sw/lv_draw_sw_polygon.c
    ../../Middlewares/lvgl/src/draw/sw/lv_draw_sw_rect.c
    ../../Middlewares/lvgl/src/draw/sw/lv_draw_sw_transform.c
    ../../Middlewares/lvgl/src/extra/lv_extra.c
    ../../Middlewares/lvgl/src/extra/layouts/flex/lv_flex.c
    ../../Middlewares/lvgl/src/extra/layouts/grid/lv_grid.c
    ../../Middlewares/lvgl/src/extra/themes/default/lv_theme_default.c
    ../../Middlewares/lvgl/src/extra/themes/basic/lv_theme_basic.c
    ../../Middlewares/lvgl/src/extra/themes/mono/lv_theme_mono.c
    ../../Middlewares/lvgl/src/extra/widgets/animimg/lv_animimg.c
    ../../Middlewares/lvgl/src/extra/widgets/calendar/lv_calendar.c
    ../../Middlewares/lvgl/src/extra/widgets/calendar/lv_calendar_header_arrow.c
    ../../Middlewares/lvgl/src/extra/widgets/calendar/lv_calendar_header_dropdown.c
    ../../Middlewares/lvgl/src/extra/widgets/chart/lv_chart.c
    ../../Middlewares/lvgl/src/extra/widgets/colorwheel/lv_colorwheel.c
    ../../Middlewares/lvgl/src/extra/widgets/imgbtn/lv_imgbtn.c
    ../../Middlewares/lvgl/src/extra/widgets/keyboard/lv_keyboard.c
    ../../Middlewares/lvgl/src/extra/widgets/led/lv_led.c
    ../../Middlewares/lvgl/src/extra/widgets/list/lv_list.c
    ../../Middlewares/lvgl/src/extra/widgets/menu/lv_menu.c
    ../../Middlewares/lvgl/src/extra/widgets/meter/lv_meter.c
    ../../Middlewares/lvgl/src/extra/widgets/msgbox/lv_msgbox.c
    ../../Middlewares/lvgl/src/extra/widgets/span/lv_span.c
    ../../Middlewares/lvgl/src/extra/widgets/spinbox/lv_spinbox.c
    ../../Middlewares/lvgl/src/extra/widgets/spinner/lv_spinner.c
    ../../Middlewares/lvgl/src/extra/widgets/tabview/lv_tabview.c
    ../../Middlewares/lvgl/src/extra/widgets/tileview/lv_tileview.c
    ../../Middlewares/lvgl/src/extra/widgets/win/lv_win.c
    ../../Middlewares/lvgl/src/font/lv_font.c
    ../../Middlewares/lvgl/src/font/lv_font_dejavu_16_persian_hebrew.c
    ../../Middlewares/lvgl/src/font/lv_font_fmt_txt.c
    ../../Middlewares/lvgl/src/font/lv_font_loader.c
    ../../Middlewares/lvgl/src/font/lv_font_montserrat_8.c
    ../../Middlewares/lvgl/src/font/lv_font_montserrat_10.c
    ../../Middlewares/lvgl/src/font/lv_font_montserrat_12.c
    ../../Middlewares/lvgl/src/font/lv_font_montserrat_12_subpx.c
    ../../Middlewares/lvgl/src/font/lv_font_montserrat_14.c
    ../../Middlewares/lvgl/src/font/lv_font_montserrat_16.c
    ../../Middlewares/lvgl/src/font/lv_font_montserrat_18.c
    ../../Middlewares/lvgl/src/font/lv_font_montserrat_20.c
    ../../Middlewares/lvgl/src/font/lv_font_montserrat_22.c
    ../../Middlewares/lvgl/src/font/lv_font_montserrat_24.c
    ../../Middlewares/lvgl/src/font/lv_font_montserrat_26.c
    ../../Middlewares/lvgl/src/font/lv_font_montserrat_28.c
    ../../Middlewares/lvgl/src/font/lv_font_montserrat_28_compressed.c
    ../../Middlewares/lvgl/src/font/lv_font_montserrat_30.c
    ../../Middlewares/lvgl/src/font/lv_font_montserrat_32.c
    ../../Middlewares/lvgl/src/font/lv_font_montserrat_34.c
    ../../Middlewares/lvgl/src/font/lv_font_montserrat_36.c
    ../../Middlewares/lvgl/src/font/lv_font_montserrat_38.c
    ../../Middlewares/lvgl/src/font/lv_font_montserrat_40.c
    ../../Middlewares/lvgl/src/font/lv_font_montserrat_42.c
    ../../Middlewares/lvgl/src/font/lv_font_montserrat_44.c
    ../../Middlewares/lvgl/src/font/lv_font_montserrat_46.c
    ../../Middlewares/lvgl/src/font/lv_font_montserrat_48.c
    ../../Middlewares/lvgl/src/font/lv_font_simsun_16_cjk.c
    ../../Middlewares/lvgl/src/font/lv_font_unscii_8.c
    ../../Middlewares/lvgl/src/font/lv_font_unscii_16.c
    ../../Middlewares/lvgl/src/hal/lv_hal_disp.c
    ../../Middlewares/lvgl/src/hal/lv_hal_indev.c
    ../../Middlewares/lvgl/src/hal/lv_hal_tick.c
    ../../Middlewares/lvgl/src/misc/lv_anim.c
    ../../Middlewares/lvgl/src/misc/lv_anim_timeline.c
    ../../Middlewares/lvgl/src/misc/lv_area.c
    ../../Middlewares/lvgl/src/misc/lv_async.c
    ../../Middlewares/lvgl/src/misc/lv_bidi.c
    ../../Middlewares/lvgl/src/misc/lv_color.c
    ../../Middlewares/lvgl/src/misc/lv_fs.c
    ../../Middlewares/lvgl/src/misc/lv_gc.c
    ../../Middlewares/lvgl/src/misc/lv_ll.c
    ../../Middlewares/lvgl/src/misc/lv_log.c
    ../../Middlewares/lvgl/src/misc/lv_lru.c
    ../../Middlewares/lvgl/src/misc/lv_math.c
    ../../Middlewares/lvgl/src/misc/lv_mem.c
    ../../Middlewares/lvgl/src/misc/lv_printf.c
    ../../Middlewares/lvgl/src/misc/lv_style.c
    ../../Middlewares/lvgl/src/misc/lv_style_gen.c
    ../../Middlewares/lvgl/src/misc/lv_templ.c
    ../../Middlewares/lvgl/src/misc/lv_timer.c
    ../../Middlewares/lvgl/src/misc/lv_tlsf.c
    ../../Middlewares/lvgl/src/misc/lv_txt.c
    ../../Middlewares/lvgl/src/misc/lv_txt_ap.c
    ../../Middlewares/lvgl/src/misc/lv_utils.c
    ../../Middlewares/lvgl/src/widgets/lv_arc.c
    ../../Middlewares/lvgl/src/widgets/lv_bar.c
    ../../Middlewares/lvgl/src/widgets/lv_btn.c
    ../../Middlewares/lvgl/src/widgets/lv_btnmatrix.c
    ../../Middlewares/lvgl/src/widgets/lv_canvas.c
    ../../Middlewares/lvgl/src/widgets/lv_checkbox.c
    ../../Middlewares/lvgl/src/widgets/lv_dropdown.c
    ../../Middlewares/lvgl/src/widgets/lv_img.c
    ../../Middlewares/lvgl/src/widgets/lv_label.c
    ../../Middlewares/lvgl/src/widgets/lv_line.c
    ../../Middlewares/lvgl/src/widgets/lv_objx_templ.c
    ../../Middlewares/lvgl/src/widgets/lv_roller.c
    ../../Middlewares/lvgl/src/widgets/lv_slider.c
    ../../Middlewares/lvgl/src/widgets/lv_switch.c
    ../../Middlewares/lvgl/src/widgets/lv_table.c
    ../../Middlewares/lvgl/src/widgets/lv_textarea.c
    ../../Middlewares/lvgl/demos/widgets/lv_demo_widgets.c
    ../../Middlewares/lvgl/demos/widgets/assets/img_clothes.c
    ../../Middlewares/lvgl/demos/widgets/assets/img_demo_widgets_avatar.c
    ../../Middlewares/lvgl/demos/widgets/assets/img_lvgl_logo.c
    ../../Middlewares/lvgl/demos/benchmark/lv_demo_benchmark.c
    ../../Middlewares/lvgl/demos/benchmark/assets/img_benchmark_cogwheel_alpha16.c
    ../../Middlewares/lvgl/demos/benchmark/assets/img_benchmark_cogwheel_argb.c
    ../../Middlewares/lvgl/demos/benchmark/assets/img_benchmark_cogwheel_chroma_keyed.c
    ../../Middlewares/lvgl/demos/benchmark/assets/img_benchmark_cogwheel_indexed16.c
    ../../Middlewares/lvgl/demos/benchmark/assets/img_benchmark_cogwheel_rgb.c
    ../../Middlewares/lvgl/demos/benchmark/assets/img_benchmark_cogwheel_rgb565a8.c
    ../../Middlewares/lvgl/demos/benchmark/assets/lv_font_bechmark_montserrat_12_compr_az.c.c
    ../../Middlewares/lvgl/demos/benchmark/assets/lv_font_bechmark_montserrat_16_compr_az.c.c
    ../../Middlewares/lvgl/demos/benchmark/assets/lv_font_bechmark_montserrat_28_compr_az.c.c
)

set(LINKER_SCRIPT ${CMAKE_SOURCE_DIR}/linker/STM32F411CEUX_FLASH.ld)

add_link_options(-Wl,-gc-sections,--print-memory-usage,-Map=${PROJECT_BINARY_DIR}/${PROJECT_NAME}.map)
add_link_options(-mcpu=cortex-m4 -mthumb -mthumb-interwork)
add_link_options(-T ${LINKER_SCRIPT})

add_link_options(-specs=nosys.specs -u _printf_float)
# 创建可执行文件目标，包括源文件和链接脚本
add_executable(${PROJECT_NAME}.elf ${SOURCES} ${LINKER_SCRIPT})
# 数学函数需要用到
target_link_libraries(${PROJECT_NAME}.elf  m)

set(HEX_FILE ${PROJECT_BINARY_DIR}/${PROJECT_NAME}.hex)
set(BIN_FILE ${PROJECT_BINARY_DIR}/${PROJECT_NAME}.bin)

add_custom_command(TARGET ${PROJECT_NAME}.elf POST_BUILD
        COMMAND ${CMAKE_OBJCOPY} -Oihex $<TARGET_FILE:${PROJECT_NAME}.elf> ${HEX_FILE}
        COMMAND ${CMAKE_OBJCOPY} -Obinary $<TARGET_FILE:${PROJECT_NAME}.elf> ${BIN_FILE}
        COMMENT "Building ${HEX_FILE}
Building ${BIN_FILE}")
